<?php if (!defined('THINK_PATH')) exit();?><section class="content-header">
	<h1>
		内容管理
	</h1>
	<ol class="breadcrumb">
		<li><a href="<?php echo U('/Admin/index');?>"><i class="fa fa-home"></i>首页</a></li>
		<li class="active">内容管理</li>
	</ol>
</section>
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<div class="box box-danger">
				<div class="box-body">
					<form id="content_edit_news_form" onsubmit="return contentEditNewsFormSubmit()">
						<table width="100%" cellpadding="2" class="table">
							<tr>
								<td width="100">标题：</td>
								<td width="450"><input type="text" name="info[title]" value="<?php echo ($info["title"]); ?>" style="width:100%" /></td>
								<td></td>
							</tr>
							<!--<tr>-->
								<!--<td>关键字：</td>-->
								<!--<td><input type="text" name="info[keywords]" value="<?php echo ($info["keywords"]); ?>" style="width:100%" /></td>-->
								<!--<td></td>-->
							<!--</tr>-->
							<tr>
								<td>描述：</td>
								<td colspan="2"><textarea name="info[description]" style="width:90%;height:60px"><?php echo ($info["description"]); ?></textarea></td>
							</tr>
							<tr>
								<td>作者：</td>
								<td><input type="text" name="info[username]" value="<?php echo ($info["username"]); ?>" style="width:60%" /></td>
								<td></td>
							</tr>
							<tr>
								<td>缩略图：</td>
								<td>
									<div style="width: 110px;float: left;">
										<img id="content_add_news_form_thumb1" src="<?php echo ($info["thumb"]); ?>"  alt="上传图片"
											 style="width:100px;height:100px;display:block;border:1px solid #ddd;padding:2px;<?php if(empty($info[thumb])): ?>display:none;<?php endif; ?>"/>
										<input type="hidden" name="info[thumb]" id="thumb1" value="<?php echo ($info["thumb"]); ?>"/>
										<input id="form_up_file1" type="file" tabindex="-1" name="filedata" size="13" style="width: 1px;height: 1px">
										<button class="btn btn-info pull-left" type="button"
												onclick="return thumbUpload('form_up_file1');">点击上传缩略图
										</button>
									</div>
								</td>
								<td></td>
							</tr>
							<tr>
								<td>内容：</td>
								<td colspan="2"><textarea id="content_edit_news_form_textarea_editor" name="info[content]" style="width:90%;height:360px" ><?php echo ($info["content"]); ?></textarea></td>
							</tr>
							<tr>
								<td>转向链接：</td>
								<td colspan="2">
									<label><input type="checkbox" class="minimal"  name="info[islink]" value="1" id="contentEditNewsFormLink" <?php if(($info["islink"]) == "1"): ?>checked<?php endif; ?> /> 启用 </label>&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="text" id="returnUrl" name="info[url]" <?php if(($info["islink"]) == "1"): ?>value="<?php echo ($info["url"]); ?>"<?php else: ?>value="http://" disabled<?php endif; ?> style="width:50%" />
								</td>
							</tr>
							<tr>
								<td>状态：</td>
								<td>
									<label>
										<input type="checkbox" class="minimal" name="info[status]" value="1" <?php if(($info["status"]) == "1"): ?>checked<?php endif; ?> /> 发布 </label>
								</td>
								<td></td>
							</tr>
						</table>
						<div class="box-footer">
                            <span class="input-group-btn">
                                <button class="btn btn-primary pull-left" type="button" id='form_submit' onclick="$('#content_edit_news_form').submit()">提交</button>
                            </span>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</section>

<script type="text/javascript">
$(document).ready(function(){
	//转向链接
	$('#contentEditNewsFormLink').on('ifChecked', function(event){
		$('#returnUrl').attr('disabled', false);
	});
	$('#contentEditNewsFormLink').on('ifUnchecked', function(event){
		$('#returnUrl').attr('disabled', true);
	});
	$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
		checkboxClass: 'icheckbox_minimal-blue',
		radioClass: 'iradio_minimal-blue'
	});
	//初始化编辑器
//	$('#content_add_news_form_textarea_editor').xheditor(xheditorSetting);
	CKEDITOR.replace( 'content_edit_news_form_textarea_editor',
			{
				filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
				filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?type=Images',
//				filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&ckCsrfToken=<?php echo cookie("ckCsrfToken");?>',
				filebrowserImageUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'
			} );

	<!-- 缩略图上传 -->
	var action = "<?php echo U('Upload/thumb', array('width'=>100, 'height'=>100));?>";
	fileupload(action,$("#form_up_file1"),$("#thumb1"),$("#content_add_news_form_thumb1"),"",true);
})

//表单提交
function contentEditNewsFormSubmit(){
	$('#content_edit_news_form_textarea_editor').val(CKEDITOR.instances.content_edit_news_form_textarea_editor.getData());
	$.post("<?php echo U('Content/add_news_iframe',array('catid'=>$catid,'id'=>$info[id]) );?>", $("#content_edit_news_form").serialize(), function(res){
		if(!res.status){
			parent.$.messager.alert('提示信息', res.info, 'error');
		}else{
			parent.$.messager.alert('提示信息', res.info, 'info');
			var url = "<?php echo U('Content/index',array('catid'=>$catid));?>";
			loadContent(url);
		}
	});
	return false;
}

</script>

</body>
</html>